package jjn.carl.greedy;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/7/29 20:07
 */
public class LeetCode55 {
    public boolean canJump(int[] nums) {
        if (nums.length == 1) {
            return true;
        }
        int coverage = 0;
        for (int i = 0; i <= coverage; i++) {
            coverage = Math.max(i + nums[i], coverage);
            if (coverage >= nums.length - 1) {
                return true;
            }
        }
        return false;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] nums = new int[count];
        for (int i = 0; i < count; i++) {
            nums[i] = scanner.nextInt();
        }
        boolean canJump = new LeetCode55().canJump(nums);
        System.out.println(canJump);
    }
}
